package com.corpdata.system.org.dao;

import java.util.List;

import org.apache.ibatis.annotations.Select;

import com.corpdata.core.base.BaseMapper;
import com.corpdata.system.org.entity.OrgPermission;
import com.github.pagehelper.Page;

public interface OrgPermissionMapper extends BaseMapper<OrgPermission>{
	
	Page<OrgPermission> selectAll();

    List<String> getPermissionsByUser(String userid);
    
    /**
     * 根据用户ID查询权限 同时返回权限范围 
     * 注意：这里只会保存该用户对的应角色 有权限范围的权限 （*好好读读*）
     * @param userid
     * @return permission:权限; rangeType:权限范围
     */
    @Select("select d.permission,a.range_type rangeType " + 
    		"from org_range a " + 
    		"inner join org_range_map b on a.id=b.fk_range " + 
    		"inner join org_user_role c on c.fk_role=b.fk_role " + 
    		"inner join org_permission d on d.id=b.fk_permission " + 
    		"where c.Userid=#{userid}")
    List<OrgPermission> selectPermissionRangeByUserid(String userid);
    
}